package com.bt.dmdb.json.converter;

import java.io.IOException;

import org.joda.time.LocalDate;
import org.joda.time.LocalDateTime;

import com.bt.dmdb.enums.DateFormat;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;

public class JsonDateSerializer extends JsonSerializer<LocalDateTime> {

    @Override
    public void serialize(LocalDateTime dt, JsonGenerator generator, SerializerProvider provider) throws IOException, JsonProcessingException {
        if (dt != null) generator.writeString(DateFormat.UI.dtf.print(dt));
    }
}
